//
//  ViewController.m
//  --百度
//
//  Created by 何典钊 on 2016/12/18.
//  Copyright © 2016年 hedianzhao. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic, strong) UIWebView *webView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    [self setupUI];
}

#pragma mark - 搭建界面
- (void)setupUI
{
    NSURL *url = [NSURL URLWithString:@"https://baidu.com"];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setValue:@"iphone AppleWebKit" forHTTPHeaderField:@"User-Agent"];
    
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
        if (connectionError != nil) {
            return ;
        }
        NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
        [_webView loadHTMLString:string baseURL:url];
    }];
}

//关闭状态栏
- (BOOL)prefersStatusBarHidden
{
    return YES;
}





@end
